


#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int w[110][110];//w[i][j]表示第i朵花在第j个花瓶的价值
int dp[110][110];//dp[i][j]表示前i朵花放在前j个花瓶的总价值的最大值
int f,v;
long long res=0;
void print(int i,int j)
{
    if(i==0||j==0)return ;
    while(dp[i][j]==dp[i][j-1]) j--;
    print(i-1,j-1);
    cout<<j<<" ";
}
int main()
{
	close();
    cin >> f >> v;
    for (int i = 1; i <= f; i ++ )
    {
        for (int j = 1; j <= v; j ++ )
        {
            cin >> w[i][j];
        }
    }

    for (int i = 1; i <= f; i ++ )
    {
    	for (int j = i; j <= v; j ++ )
        {
            if(i==j) dp[i][j]=dp[i-1][j-1]+w[i][j];
            //如果没有考虑i==j的情况，若此时dp[i-1][j-1]+w[i][j]为负，而dp[i][j-1]初始为0，则状态错误！
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j-1]+w[i][j]);
        }
    }
        
    cout << dp[f][v] << endl;        
    print(f,v);
    return 0;   
}
